package collectionexercise02;

import java.util.*;

public class SortInteger {
    public static void main(String[] args) {
        List<Integer> list=new ArrayList<>();
        Random rand=new Random();
        for (int i=0;i<10;i++){
            list.add(rand.nextInt(100) );
        }
        System.out.println("list:"+list);
        //比较器
        list.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });
        System.out.println("list升序:"+list);

        Collections.sort(list, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });
        System.out.println("list降序："+list);

        Collections.sort(list);
        System.out.println("list升序:"+list);
        Collections.reverse(list);
        System.out.println("list降序："+list);


    }
}
